#coding=utf-8
import math
import time

DEMO=1
SMGP13=2
SMGP20=3
SMGP30=4
SMPP=5
CMPP30=6
SGIP=7
CNGP=8

def bin2hexstr(s):
    return " ".join(["%.02X" % ord(__c) 
                     for __c in s ])
    
def m2hex(m):
    s = m.toStr()
    temp = ''
    k = 0
    for i in range(int(math.ceil(len(s)/4.0))):
        temp += bin2hexstr(s[i*4:(i+1)*4])
        k += 1
        if k % 4 == 0:
            temp += '\n'
        else:
            if k % 2 == 0:
                temp += '    '
            else:
                temp += '  '
        
    return temp
            
def timestring(t=time.gmtime()):
    s = time.strftime('%y%m%d%H%M%S', t) + '008+'
    return s



    
